//
//  CollectionTableViewCell.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/14.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "VideoTableViewCell.h"

@interface VideoTableViewCell ()

@property(nonatomic,strong) UIView *baseView;

@end

@implementation VideoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        CGFloat baseHeight = kScreenIp6(70);
        CGFloat baseY = kScreenIp6(10);
        CGFloat baseX = kScreenIp6(10);
        CGFloat baseWidth = kScreenWidth - baseX;
        self.baseView = [[UIView alloc] initWithFrame:CGRectMake(baseX, baseY, baseWidth, baseHeight)];
        
        self.leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenIp6(100), baseHeight)];
        [self.baseView addSubview:_leftImageView];
        
        CGFloat labelWidth = baseWidth - self.leftImageView.bounds.size.width - kScreenIp6(40);
        self.type = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.leftImageView.frame) + kScreenIp6(20), 0, labelWidth, kScreenIp6(20))];
        self.type.textColor = [UIColor grayColor];
        self.type.font = [UIFont systemFontOfSize:12];
        [self.baseView addSubview:_type];
        
        self.title = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.type.frame), CGRectGetMaxY(self.type.frame), labelWidth, kScreenIp6(30))];
        self.title.font = [UIFont systemFontOfSize:15];
        [self.baseView addSubview:_title];
        
        UILabel *time = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.type.frame), CGRectGetMaxY(self.title.frame),  kScreenIp6(40), kScreenIp6(20))];
        time.text = @"时间:";
        time.textColor = [UIColor grayColor];
        // time.textColor = [UIColor colorWithWhite:0.251 alpha:1.000];
        time.font = [UIFont systemFontOfSize:12];
        [self.baseView addSubview:time];
        
        self.beginTime = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(time.frame), CGRectGetMaxY(self.title.frame), labelWidth - time.bounds.size.width, kScreenIp6(20))];
        self.beginTime.font = [UIFont systemFontOfSize:12];
        [self.baseView addSubview:_beginTime];
        
        UIImageView *arrowImageView = [[UIImageView alloc] initWithFrame:CGRectMake(baseWidth - kScreenIp6(40), (baseHeight - kScreenIp6(36))/2, kScreenIp6(36), kScreenIp6(36))];
        arrowImageView.image = [UIImage imageNamed:@"set_arrow_next"];
        [self.baseView addSubview:arrowImageView];
        
        [self addSubview:_baseView];
        
        
        
        //线
        UIView *footLineView = [[UIView  alloc]initWithFrame:CGRectMake( 0, kScreenIp6(90-1), kScreenWidth, 0.5)];
        
        footLineView.backgroundColor = [UIColor colorWithWhite:0.699 alpha:1.000];
        
        [self addSubview:footLineView];
        
        
        
    }
    return self;
}


- (void)setModelWith:(JijinVideoModel *)model
{
    [self.leftImageView setImageWithURL:[NSURL URLWithString:model.recordingCover] placeholderImage:[UIImage imageNamed:@"no_pic"]];
    
    NSArray *type = [model.name componentsSeparatedByString:@" "];
    self.type.text = type[0];
    
    self.title.text = model.showName;
    self.beginTime.text = model.timeName;
}


@end
